package com.mm.demo.thymeleafdemo.controller;

import com.mm.demo.thymeleafdemo.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import java.util.Arrays;
import java.util.Date;

@Controller
public class HelloController {

    @GetMapping("show1")
    public String show1(Model model){
        model.addAttribute("msg", "Hello, Thymeleaf!");
        return "hello";
    }
    @GetMapping("show2")
    public String show2(Model model){
        User user = new User();
        user.setAge(21);
        user.setName("MIMI");
        user.setFriend(new User("shasha",30));
        model.addAttribute("user",user);
        return "user";
    }
    @GetMapping("show4")
    public String show4(Model model){
        User user = new User();
        user.setAge(21);
        user.setName("MIMI");

        model.addAttribute("users", Arrays.asList(user,user,user));
        return "show4";
    }
    @GetMapping("show3")
    public String show3(Model model){
        model.addAttribute("today",new Date());
        return "show3";
    }

}